import 'package:boss/models/delivery_setting_data.dart';
import 'package:boss/ui/page/takeoutManagement/page/deliveryFeeSetting/provider/delivery_provider.dart';
import 'package:boss/ui/widget/button/fixed_bottom_btn.dart';
import 'package:boss/ui/widget/column_divier.dart';
import 'package:boss/ui/widget/loader/loader.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'delivery_free_panel.dart';
import 'delivery_rule_panel.dart';

class DeliveryFeeBrowser extends StatefulWidget {
  @override
  _DeliveryFeeBrowserState createState() => _DeliveryFeeBrowserState();
}

class _DeliveryFeeBrowserState extends State<DeliveryFeeBrowser> {
  @override
  Widget build(BuildContext context) {
    final provider = Provider.of<DeliveryProvider>(
      context,
      listen: false,
    );

    return Loader<DeliverySettingData>(
      loadTask: provider.initData,
      builder: (context) => Column(
        children: <Widget>[
          Expanded(
            child: SingleChildScrollView(
              padding: EdgeInsets.symmetric(vertical: 30.w),
              child: ColumnDivier(
                itemPadding: true,
                children: <Widget>[
                  DeliveryRulePanel(),
                  DeliveryFreePanel(),
                ],
              ),
            ),
          ),
          FixedBottomBtn(
            title: '保存',
            onTap: () async {
              provider.update();
            },
          ),
        ],
      ),
    );
  }
}
